// 监听包装
const UTIL = require("./util");


// 玩家模块 ================================
const PLAYER = require("./player");
// 玩家精灵
/** @type {PIXI.Sprite} */
const playerSprite = PLAYER.playerSprite;
// 玩家数据
const player = PLAYER.player;

// 背景模块 =================================
const BACKGROUND = require("./background");
// 背景精灵
const getBackgroundSprite = BACKGROUND.getBackgroundSprite;
console.log("获得引用");

// 注册方向键
// 左
const left = UTIL.key(37);
left.press = function () {
    player.nowXSpeed = -player.xSpeed;
}

left.release = function () {
    player.nowXSpeed = 0;
}

// 右
const right = UTIL.key(39);
right.press = function () {
    player.nowXSpeed = player.xSpeed;
}

right.release = function () {
    player.nowXSpeed = 0;
}

// 上
const top = UTIL.key(38);
top.press = function () {
    player.nowYSpeed = -player.ySpeed;
}
top.release = function () {
    player.nowYSpeed = 0;
}

// 下
const down = UTIL.key(40);
down.press = function () {
    player.nowYSpeed = player.ySpeed;
}
down.release = function () {
    player.nowYSpeed = 0;
}

// L键打印未知
const L = UTIL.key(76);
L.press = function () {
    console.log("x " + getBackgroundSprite().x);
    console.log("y " + getBackgroundSprite().y);
    console.log("width " + getBackgroundSprite().width);
    console.log("height " + getBackgroundSprite().height);
}